package com.design.memento.clone;

/**
 * @ClassName Originator.java
 * @Description 发起人自主备份和恢复
 * @author Jon
 * @date 2018年6月20日 下午5:28:26
 */
public class Originator implements Cloneable{
	private String status;
	private Originator backup;
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public void createMemento() throws CloneNotSupportedException {
		this.backup = this.clone();
	}
	public void restoreMemento() {
		this.status = this.backup.status;
	}
	
	//克隆当前对象当做是备忘录
	@Override
	protected Originator clone() throws CloneNotSupportedException {
		return (Originator)super.clone();
	}
}
